package com.le.tester.onjava8.l_3_2;


import com.le.tester.onjava8.l_3_1.HTMLColors;

import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * createTime：2023/2/6 13:49
 * description：list的行为
 */
public class ListOps {

    static final List<String> LIST = HTMLColors.LIST.subList(0, 3);
    private static boolean b;
    private static String s;
    private static int i;
    private static Iterator<String> it;
    private static ListIterator<String> lit;

    public static void basicTest(List<String> a) {
        a.add(1, "x");

        //直接新增列表的末尾
        a.add("x");
        a.addAll(LIST);
        //某个位置插入一个LIST
        a.addAll(3, LIST);
        b = a.contains("1");

        b = a.containsAll(LIST);

        s = a.get(1);


    }

    public static void iterMotion(List<String> a) {
        ListIterator<String> it = a.listIterator();
        b = it.hasNext();
        b = it.hasPrevious();

        s = it.next();
        i = it.nextIndex();
        s = it.previous();
        i = it.previousIndex();

    }
}
